<%@page import="com.kaishengit.entity.Todo"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML>
<html>
  <head>
    <title>修改todo</title>
    <link rel="stylesheet" href="http://lib.sinaapp.com/js/bootstrap/2.2.1/css/bootstrap.min.css">
  </head>
  <body>
  	<div class="container">
  		<%
  			Todo todo = (Todo)request.getAttribute("todo"); 
  			if(todo == null) {
  				response.sendRedirect("list.jsp");
  				return;
  			}
  		 %>
  	
  		<form id="todoForm" action="update.jsp" method="post">
	    	<fieldset>
	    		<legend>修改Todo</legend>
	    		<label>Todo</label>
	    		<input type="hidden"  name="id" value="<%=todo.getId() %>">
	    		<input type="text" id="todo" name="todo" value="<%=todo.getTodo() %>">
	    		<span class="help-block hide" style="color:red">todo不能为空</span>
	    		<br>
	    		<button type="button" class="btn btn-primary">编辑</button>
	    	</fieldset>
	    </form>
  	</div>
  <script type="text/javascript" src="http://lib.sinaapp.com/js/jquery/2.0.2/jquery-2.0.2.min.js"></script>
  <script type="text/javascript">
  	$(document).ready(function(){
  		$("button").click(function(){
  			var todo = $("#todo").val();
  			if(!todo) {
  				$(".help-block").show();
  				$("#todo").focus();
  			} else {
  				$("#todoForm").submit();
  			}
  		});
  	});	
  </script>
  </body>
</html>
